package com.chixing.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.chixing.entity.CommentImage;
import com.chixing.mapper.CommentImageMapper;
import com.chixing.service.ICommentImageService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.chixing.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author smith
 * @since 2025-09-30
 */
@Service
public class CommentImageServiceImpl  implements ICommentImageService {
    @Autowired
    private CommentImageMapper commentImageMapper;
    @Override
    public Result deleteCommentImage(Long commentId) {
        QueryWrapper<CommentImage> wrapper = new QueryWrapper<>();
        wrapper.eq("comment_id", commentId);
        int rows = commentImageMapper.delete(wrapper);

        if(rows >= 0) {  // 即使没有图片也要返回成功
            return Result.deleteSuccess("图片删除成功");
        }
        return Result.deleteFail("图片删除失败");
    }

}
